package com.sing;


import com.sing.enuns.ResponseStatusEnum;

public class CommonResponse {
    private String resCode;
    private String resMsg;
    private Object data;
    
    public CommonResponse(){
    	
    }
    public CommonResponse(String resCode, String resMsg, Object data) {
        super();
        this.resCode = resCode;
        this.resMsg = resMsg;
        this.data = data;
    }

    public String getResCode() {
		return resCode;
	}
	public void setResCode(String resCode) {
		this.resCode = resCode;
	}
	public String getResMsg() {
		return resMsg;
	}
	public void setResMsg(String resMsg) {
		this.resMsg = resMsg;
	}
	public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static CommonResponse fail() {
        return new CommonResponse(ResponseStatusEnum.EXCEPTION.resCode, ResponseStatusEnum.EXCEPTION.msg, "");
    }

    public static CommonResponse fail(Object data) {
        return new CommonResponse(ResponseStatusEnum.EXCEPTION.resCode, ResponseStatusEnum.EXCEPTION.msg, data);
    }
    
    public static CommonResponse fail(String msg) {
        return new CommonResponse(ResponseStatusEnum.EXCEPTION.resCode,msg, null);
    }
    
    public static CommonResponse success(Object data) {
        return new CommonResponse(ResponseStatusEnum.ACCEPT.resCode, ResponseStatusEnum.ACCEPT.msg, data);
    }

    public static CommonResponse error(String errorCode,String msg,Object data) {
        return new CommonResponse(errorCode, msg, data);
    }

    public static CommonResponse error(String errorCode,String msg) {
        return new CommonResponse(errorCode, msg, null);
    }
    
    public boolean checkSuccess() {
    	if(ResponseStatusEnum.ACCEPT.resCode.equals(resCode)) {
    		return true;
    	}
    	return false;
    }

}
